<%--
  Created by IntelliJ IDEA.
  User: 86137
  Date: 2021/8/2
  Time: 18:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>index</title>
    <style>
        a {
            text-decoration: pink;
        }

        img {
            display: none;
        }
    </style>

</head>
<body>
<img src="img/cz1024.jpg" id="banner"/>


<%--首先如果登录信息不为空，则为已有用户在线--%>
<c:if test="${ not empty user}">
    <span>Welcome To You :&nbsp;${user.name}</span> &nbsp;&nbsp;&nbsp;<em id="nowDate"></em><br>
    <a href="${pageContext.request.contextPath}/userServlet?method=findAll">查询用户信息</a><br>

        </c:if>
        <%--如果登录信息是空的，则让用户去登录--%>
        <c:if test="${empty user}">
          <a href="${pageContext.request.contextPath}/login.jsp">login</a>
        </c:if>


</body>

<script>
    /*两秒后显示广告图片*/
    setTimeout(function () {
        let bann = document.getElementById("banner");
        bann.style.display = "block";
    }, 2000);

    /*3秒后隐藏广告图片*/
    setTimeout(function () {
        let bann = document.getElementById("banner");
        bann.style.display="none";
    },4000);

    //动态显示系统时间
    function run(){
        var time = new Date();//获取系统当前时间
        var year = time.getFullYear();
        var month = time.getMonth()+1;
        var date= time.getDate();//系统时间月份中的日
        var day = time.getDay();//系统时间中的星期值
        var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
        var week = weeks[day];//显示为星期几
        var hour = time.getHours();
        var minutes = time.getMinutes();
        var seconds = time.getSeconds();
        console.log(seconds);
        if(month<10){
            month = "0"+month;
        }
        if(date<10){
            date = "0"+date;
        }
        if(hour<10){
            hour = "0"+hour;
        }
        if(minutes<10){
            minutes = "0"+minutes;
        }
        if(seconds<10){
            seconds = "0"+seconds;
        }
        //var newDate = year+"年"+month+"月"+date+"日"+week+hour+":"+minutes+":"+seconds;
        document.getElementById("nowDate").innerHTML = "今天是： "+year+"年 "+month+"月 "+date+"日 "+week+"，   当前时间："+hour+":"+minutes+":"+seconds;
        setTimeout('run()',1000);
    }
    run();





</script>


</html>
